//SaleOrder.java
package decorator.printinvoice;

import java.util.Date;
import java.util.Iterator;
import java.util.Vector;

/**
 * order's body
 *@author:youtubezou
 *@version:2012-7-25
 */
public class SaleOrder implements Order {
	private Vector<OrderLine> items = new Vector<OrderLine>(10);
	private String customerName;
	private Date salesDate;
	
	/*print order lines*/
	public void print(){
		Iterator<OrderLine> iter = items.iterator();
		while(iter.hasNext()){
			System.out.println(iter.next());
		}
	}

	/*add order line*/
	public void add(OrderLine item){
		items.add(item);
	}
	
	/*remove order line*/
	public void remove(OrderLine item){
		items.remove(item);
	}
	
	/*get total price of all orders*/
	public double getGrandTotal() {
		double grandTotal = 0.0;
		Iterator<OrderLine> iter = this.items.iterator();
		
		//System.out.println(items);
		
		while(iter.hasNext()){
			OrderLine line = iter.next();
			grandTotal += line.getTotalPrice();
		}
		
		return grandTotal;	
	}

	public String getCustomerName() {
		return customerName;
	}

	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}

	public Date getSalesDate() {
		return salesDate;
	}

	public void setSalesDate(Date salesDate) {
		this.salesDate = salesDate;
	}
	
}
